cmake_minimum_required(VERSION 3.2)

PROJECT(dmcurl)

LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
INCLUDE(cmake/ModuleImport.cmake)
INCLUDE(cmake/ModuleCompileOptions.cmake)
ModuleSetCompileOptions()

SET(DMCURL_VERSION_MAJOR "1")
SET(DMCURL_VERSION_MINOR "0")
SET(DMCURL_VERSION_PATCH "1")
SET(DMCURL_VERSION "${DMCURL_VERSION_MAJOR}.${DMCURL_VERSION_MINOR}.${DMCURL_VERSION_PATCH}")

MESSAGE(STATUS "VERSION: ${DMCURL_VERSION}")

ADD_DEFINITIONS(-DUSE_DMCURL)
ADD_DEFINITIONS(-DNOMINMAX)

ModuleImport("mbedtls" "thirdparty/mbedtls")
ModuleImport("curl" "thirdparty/curl")
ModuleImport("curlpp" "thirdparty/curlpp")

IF (WIN32)
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/windows)
ENDIF(WIN32)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/test)

FILE(GLOB_RECURSE DMCURL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/include/*.c
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h

${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
)

IF (WIN32)
    LIST(APPEND DMCURL_SOURCES)
ENDIF(WIN32)

ADD_LIBRARY(dmcurl STATIC ${DMCURL_SOURCES})

FILE(GLOB_RECURSE DMCURLTEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/*.c
${CMAKE_CURRENT_SOURCE_DIR}/test/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/test/*.h)

ADD_EXECUTABLE(dmcurltest ${DMCURLTEST_SOURCES})

TARGET_LINK_LIBRARIES(dmcurltest dmcurl libcurl curlpp mbedcrypto mbedx509 mbedtls)
